var target = UIATarget.localTarget();
var counter = 0;
var startdate,
starttime,
stopdate,
stoptime;
while (true) {
    startdate = new Date();
    starttime = startdate.getTime();
    //start stats
    UIALogger.logMessage("SCRIPT RUN : " + counter);
    UIALogger.logMessage("Bundle ID" + " :" + target.frontMostApp().bundleID());

    var a,
    b;
    UIALogger.logStart("Orientation Tests");
    //set orientation to landscape left
    target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPELEFT);
    a = target.frontMostApp().interfaceOrientation();
    UIALogger.logMessage("Current orientation now " + target.frontMostApp().interfaceOrientation());

    //reset orientation to portrait
    target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT);
    b = target.frontMostApp().interfaceOrientation();
    UIALogger.logMessage("Current orientation now " + target.frontMostApp().interfaceOrientation());

    if (a == b) {
        UIALogger.logPass();
    } else {
        UIALogger.logFail();
    }

    // Test Multitasking
    UIALogger.logMessage("Starting multitask testing..");
    target.deactivateAppForDuration(5);
    UIALogger.logPass("Multitasking confirmed");

    //user journey start->
    //Open article and social feed
    UIALogger.logMessage("Starting article and social feed journey");
    target.frontMostApp().mainWindow().tableViews()[0].cells()[0].scrollToVisible();
    UIATarget.localTarget().delay(1);
    target.frontMostApp().mainWindow().tableViews()[0].cells()[0].tap();
    UIATarget.localTarget().delay(1);
    UIALogger.logFail("WARNING ERROR DETECTED USING iOS5 ON THIS PAGE");
    target.frontMostApp().mainWindow().toolbar().buttons()["Share"].tap();
    target.frontMostApp().actionSheet().buttons()[0].tap();
    UIATarget.localTarget().delay(4);
    target.frontMostApp().mainWindow().buttons()["close"].tap();
    target.frontMostApp().mainWindow().toolbar().buttons()["Share"].tap();
    target.frontMostApp().actionSheet().buttons()[1].tap();
    target.frontMostApp().mainWindow().navigationBar().leftButton().tap();
    target.frontMostApp().mainWindow().toolbar().buttons()["Share"].tap();
    target.frontMostApp().actionSheet().buttons()[2].tap();
    target.frontMostApp().mainWindow().scrollViews()[0].textFields()["Message body"].scrollToVisible();
    target.frontMostApp().mainWindow().navigationBar().leftButton().tap();
    target.frontMostApp().actionSheet().buttons()["Delete Draft"].tap();
    target.frontMostApp().mainWindow().toolbar().buttons()["button invert"].tap();
    target.frontMostApp().mainWindow().toolbar().buttons()["button invert"].tap();
    target.frontMostApp().mainWindow().navigationBar().leftButton().tap();
    UIALogger.logPass("Passed social feed journey");
    //live tv journey
    target.frontMostApp().mainWindow().tabBar().buttons()["Live TV"].tap();
    target.frontMostApp().mainWindow().tableViews()[0].cells()[1].scrollToVisible();
    //Watch video journey
    UIALogger.logMessage("Starting video journey");
    target.frontMostApp().mainWindow().tabBar().buttons()["Video"].tap();
    target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["Showbiz, All the latest showbiz news and gossip"].scrollToVisible();
    target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["Showbiz, All the latest showbiz news and gossip"].tap();
    target.frontMostApp().mainWindow().navigationBar().leftButton().tap();
    target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["Radio, The top stories in audio (smaller download)"].tap();
    UIATarget.localTarget().delay(5);
    target.frontMostApp().mainWindow().navigationBar().leftButton().tap();
    UIALogger.logPass("Passed video journey");
    //your report journey
    target.frontMostApp().mainWindow().tabBar().buttons()["Your Report"].tap();

    //Blog discussion journey
    UIALogger.logMessage("Starting blog journey");
    target.frontMostApp().mainWindow().tabBar().buttons()["Discuss"].tap();
    target.frontMostApp().mainWindow().tableViews()[0].cells()["Blogs, In-depth analysis and a personal view - from our team of experts"].scrollToVisible();
    target.frontMostApp().mainWindow().tableViews()[0].cells()["Blogs, In-depth analysis and a personal view - from our team of experts"].tap();
    UIATarget.localTarget().delay(5);
    target.frontMostApp().mainWindow().navigationBar().leftButton().tap();
    target.frontMostApp().mainWindow().tabBar().buttons()["News"].tap();
    UIALogger.logPass("Blog journey done");
    stopdate = new Date();
    stoptime = startdate.getTime();

    UIALogger.logPass("Start Time : " + startdate);
    UIALogger.logPass("Stop Time  : " + stopdate);
++counter;
    UIATarget.localTarget().delay(3);
    }

